function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()


  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}

function getLanguageCode(){
  var array = [
    { code: 'auto', name: '自动检测' }, { code: 'zh',name: '中文' }, 
    { code: 'en', name: '英语' }, { code: 'yue',name: '粤语' }, 
    { code: 'wyw', name: '文言文' }, { code: 'jp',name: '日语' }, 
    { code: 'kor', name: '韩语' }, { code: 'fra', name: '法语' }, 
    { code: 'spa', name: '西班牙语' }, { code: 'th', name: '泰语' }, 
    { code: 'ara', name: '阿拉伯语' }, { code: 'ru', name: '俄语' }, 
    { code: 'pt', name: '葡萄牙语' }, { code: 'de', name: '德语' }, 
    { code: 'it', name: '意大利语' }, { code: 'el', name: '希腊语' }, 
    { code: 'nl', name: '荷兰语' }, { code: 'pl', name: '波兰语' }, 
    { code: 'bul', name: '保加利亚语' }, { code: 'est', name: '爱沙尼亚语' }, 
    { code: 'dan', name: '丹麦语' }, { code: 'fin', name: '芬兰语' }, 
    { code: 'cs', name: '捷克语' }, { code: 'rom', name: '罗马尼亚语' }, 
    { code: 'slo', name: '斯洛文尼亚语' }, { code: 'swe', name: '瑞典语' }, 
    { code: 'hu', name: '匈牙利语' }, { code: 'cht', name: '繁体中文' }, 
    { code: 'vie', name: '越南语' }
  ]
  return array;
}

module.exports = {
  formatTime: formatTime,
  getLanguageCode: getLanguageCode
}
